package com.zhentao.feign;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.zhentao.api.user.UserClientApi;
import com.zhentao.model.common.dtos.ResponseResult;
import com.zhentao.model.pay.pojo.ApUserMembership;
import com.zhentao.model.user.pojo.ApUser;
import com.zhentao.service.ApUserService;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
public class UserClient implements UserClientApi {
    @Resource
    ApUserService apUserService;
    @PostMapping("/api/v1/app/user/update")
    @Override
    public ResponseResult updateApUser(ApUserMembership apUserMembership) {
        ApUser apUser = apUserService.getById(apUserMembership.getUserId());
        apUser.setIdentity(apUserMembership.getMembershipId());
        return apUserService.updateUser(apUser);
    }
    @PostMapping("/api/v1/app/user/selectOne")
    @Override
    public ApUser selectOne(@RequestParam("id") Integer id) {
        ResponseResult result = apUserService.getByUserId(Integer.toString(id));
        ApUser apUser =(ApUser) result.getData();
        return apUser;
    }

    @PostMapping("/api/v1/app/user/updateToUser")
    @Override
    public ResponseResult updateUser(@RequestBody ApUser apUser) {
        return apUserService.updateUser(apUser);
    }
}
